package io_gin

import (
	"clean/infra/log"
	"clean/usecase/io/pb"
	"errors"
	"github.com/gin-gonic/gin"
)

func (r *Handler) Hello(c *gin.Context) {
	name := c.Query("name")
	log.Debug("Handler Hello: name=%v", name)
	in := pb.Input{
		Msg: &pb.Input_InputHello{
			InputHello: &pb.InputHello{
				Name: name,
			},
		},
	}
	out := &pb.Output{}
	r.app.Hello(in, out)
	if out.Error != nil {
		c.Error(errors.New(out.Error.Msg))
		return
	}
	c.String(200, out.GetOutputHello().Msg)
}
